﻿using UnityEngine;
using QFramework;

namespace HKTools
{
    /// <summary>
    /// HK_FirstPersonCam 测试脚本
    /// </summary>
    public class Test_FirstPersonCam : HKFirstPersonCam_BaseController
    {
        void Awake()
        {
            this.RegisterEvent<Event_FPS_ChangePos>(args =>
            {
                HKDebug.Log("FirstPerson 切换位置：" + args._posType.ToString(), LogColor.Cyan, LogStyle.Bold);
            }).UnRegisterWhenGameObjectDestroyed(gameObject);

            this.RegisterEvent<Event_FPS_Trigger>(args =>
            {
                HKDebug.Log("FirstPerson 触发：" + args._triggerType.ToString(), LogColor.Cyan, LogStyle.Bold);
            }).UnRegisterWhenGameObjectDestroyed(gameObject);
        }

        void OnGUI()
        {
            // 绘制操作提示
            GUI.skin.label.fontSize = 14;
            GUI.skin.label.normal.textColor = Color.white;

            // 绘制操作提示
            GUILayout.Space(25);
            GUILayout.Label("操作提示：");
            GUILayout.Label("1. 按住WASD键盘进行角色移动");
            GUILayout.Label("2. 按住Shift键，可加速移动");
            GUILayout.Label("3. 按住鼠标右键进行角色旋转");
            GUILayout.Label("4. 滚动鼠标中间进行视角缩放");

            GUILayout.Space(15);
            GUILayout.Label("测试按钮：");

            // 位置切换按钮
            if (GUILayout.Button("切换到位置1", GUILayout.Width(200), GUILayout.Height(30)))
            {
                this.SendCommand(new CMD_FPS_ChangePos(HK_FirstPersonPosEnum.Pos_01, true));
            }

            if (GUILayout.Button("切换到位置2", GUILayout.Width(200), GUILayout.Height(30)))
            {
                this.SendCommand(new CMD_FPS_ChangePos(HK_FirstPersonPosEnum.Pos_02, true));
            }

            if (GUILayout.Button("切换到位置3", GUILayout.Width(200), GUILayout.Height(30)))
            {
                this.SendCommand(new CMD_FPS_ChangePos(HK_FirstPersonPosEnum.Pos_03, true));
            }

            GUILayout.Space(10);

            // 触发器显示/隐藏按钮
            if (GUILayout.Button("显示所有触发器", GUILayout.Width(200), GUILayout.Height(30)))
            {
                this.SendCommand(new CMD_FPS_ShowAllTriggers());
            }

            if (GUILayout.Button("隐藏所有触发器", GUILayout.Width(200), GUILayout.Height(30)))
            {
                this.SendCommand(new CMD_FPS_HideAllTriggers());
            }

            if (GUILayout.Button("显示触发器组1", GUILayout.Width(200), GUILayout.Height(30)))
            {
                this.SendCommand(new CMD_FPS_ShowTriggersByGroup(HK_FirstPersonTriggerGroupEnum.TriggerGroup1));
            }

            if (GUILayout.Button("隐藏触发器组1", GUILayout.Width(200), GUILayout.Height(30)))
            {
                this.SendCommand(new CMD_FPS_HideTriggersByGroup(HK_FirstPersonTriggerGroupEnum.TriggerGroup1));
            }

            GUILayout.Space(10);

            // 相机固定/取消固定按钮
            if (GUILayout.Button("固定相机", GUILayout.Width(200), GUILayout.Height(30)))
            {
                Vector3 pos = this.GetSystem<IHK_FirstPersonCamSystem>().FirstPerson.transform.position;
                this.SendCommand(new CMD_FPS_FixTheCamera(pos));
            }

            if (GUILayout.Button("取消固定相机", GUILayout.Width(200), GUILayout.Height(30)))
            {
                this.SendCommand(new CMD_FPS_UnFixTheCamera());
            }
        }
    }
}